﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Runtime;
using System.Runtime.InteropServices;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging;
using System.Threading;
using System.Reflection;

using PickGold.Handler;

namespace PickGold.Generic
{
	/// <summary>
	/// 能用类
	/// </summary>
	public static class Common
	{
	}

	/// <summary>
	/// 通用类
	/// </summary>
	/// <typeparam name="T0">值一的类型</typeparam>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class Common<T0> : ICommon<T0>, ICommon,
		IAsyncResult, IComparable, IComparer,
		ICollection, IEqualityComparer, IEnumerable, IEnumerator, IList, IDictionary,
		IMethodCallMessage, IMethodReturnMessage, IMethodMessage, IMessage,
		IDisposable
	{
		/// <summary>
		/// 默认类型值，只读
		/// </summary>
		[Obsolete("请使用 PickGold.Reflector.Generic<>.DefaultValue 静态只读成员变量访问。")]
		public static T0 DefaultValue
		{
			get
			{
				return Reflector.Generic<T0>.DefaultValue;
			}
		}

		/// <summary>
		/// 空指针类型数组对象，只读
		/// </summary>
		[Obsolete("请使用 PickGold.Reflector.Generic<>.NullArray 静态只读成员变量访问。")]
		public static T0[] NullArray
		{
			get
			{
				return Reflector.Generic<T0>.NullArray;
			}
		}

		/// <summary>
		/// 零长度类型数组对象，只读
		/// </summary>
		[Obsolete("请使用 PickGold.Reflector.Generic<>.EmptyArray 静态只读成员变量访问。")]
		public static T0[] EmptyArray
		{
			get
			{
				return Reflector.Generic<T0>.EmptyArray;
			}
		}

		/// <summary>
		/// 已初始化的属性标志，位数据
		/// </summary>
		protected int Initialized = 0;

		/// <summary>
		/// 值一
		/// </summary>
		public T0 V0;
		/// <summary>
		/// 值托管一
		/// </summary>
		public HByReturnDelegate<T0, T0> H0;

		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		public Common()
		{
			this.Initialize();
		}
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="v0">值一</param>
		public Common(T0 v0)
		{
			this.Initialize();
			this.V0 = v0;
		}
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="h0">值托管一</param>
		public Common(HByReturnDelegate<T0, T0> h0)
		{
			this.Initialize();
			this.H0 = h0;
		}

		/// <summary>
		/// 构造初始化
		/// </summary>
		protected virtual void Initialize()
		{
		}

		/// <summary>
		/// 属性值一
		/// </summary>
		public T0 Value0
		{
			set
			{
				this.V0 = value;
			}
			get
			{
				if (this.H0 != null && (this.Initialized & BitUtil.B32_00) == BitUtil.B32_ZERO)
				{
					this.V0 = this.Handler0(this.V0);
					this.Initialized &= BitUtil.B32_00;
				}
				return this.V0;
			}
		}

		/// <summary>
		/// 属性值托管一
		/// </summary>
		public HByReturnDelegate<T0, T0> Handler0
		{
			set
			{
				this.H0 = value;
			}
			get
			{
				return this.H0;
			}
		}

		/// <summary>
		/// 取指定类型值
		/// </summary>
		/// <typeparam name="T">指定的类型</typeparam>
		/// <param name="defaultValue">默认值</param>
		/// <returns>值列表中符合类型的值</returns>
		public T GetValue<T>(T defaultValue)
		{
			var ts = this.GetTypes();
			var os = this.GetValues();
			for (var i = ts.Length - 1; i >= 0; i--)
			{
				if (ts[i] == typeof(T))
					return (T)os[i];
			}

			foreach (var o in os)
			{
				if (o is T)
					return (T)o;
			}

			//throw new InvalidCastException();
			return defaultValue;
		}

		/// <summary>
		/// 取指定类型值
		/// </summary>
		/// <typeparam name="T">指定的类型</typeparam>
		/// <param name="defaultValue">默认值</param>
		/// <returns>值列表中符合类型的值</returns>
		public HByReturnDelegate<T, T> GetHandler<T>(HByReturnDelegate<T, T> defaultValue)
		{
			var ts = this.GetTypes();
			var hs = this.GetHandlers();
			for (var i = ts.Length - 1; i >= 0; i--)
			{
				if (ts[i] == typeof(T))
					return hs[i] as HByReturnDelegate<T, T>;
			}

			foreach (var h in hs)
			{
				var hh = h as HByReturnDelegate<T, T>;
				if (hh != null)
					return hh;
			}

			//throw new InvalidCastException();
			return defaultValue;
		}

		/// <summary>
		/// 取所有值类型
		/// </summary>
		/// <returns>所有值类型</returns>
		public virtual Type[] GetTypes()
		{
			return new Type[] { typeof(T0), };
		}

		/// <summary>
		/// 取所有值委托
		/// </summary>
		/// <returns>所有值委托</returns>
		public virtual Delegate[] GetHandlers()
		{
			return new Delegate[] { this.H0, };
		}

		/// <summary>
		/// 取所有值
		/// </summary>
		/// <returns>所有值</returns>
		public virtual object[] GetValues()
		{
			return new object[] { this.V0, };
		}

		/// <summary>
		/// 返回表示当前 System.Object 的 System.String。
		/// </summary>
		/// <returns>System.String，表示当前的 System.Object。</returns>
		public override string ToString()
		{
			return base.ToString() + ";V0:" + this.V0;
		}

		#region ICommon<T0> 成员

		T0 ICommon<T0>.Value
		{
			set
			{
				this.Value0 = value;
			}
			get
			{
				return this.Value0;
			}
		}

		HByReturnDelegate<T0, T0> ICommon<T0>.Handler
		{
			set
			{
				this.H0 = value;
			}
			get
			{
				return this.H0;
			}
		}

		#endregion

		#region IAsyncResult 成员

		object IAsyncResult.AsyncState
		{
			get
			{
				var v = this.V0 as IAsyncResult;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IAsyncResult type.");

				return v.AsyncState;
			}
		}

		WaitHandle IAsyncResult.AsyncWaitHandle
		{
			get
			{
				var v = this.V0 as IAsyncResult;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IAsyncResult type.");

				return v.AsyncWaitHandle;
			}
		}

		bool IAsyncResult.CompletedSynchronously
		{
			get
			{
				var v = this.V0 as IAsyncResult;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IAsyncResult type.");

				return v.CompletedSynchronously;
			}
		}

		bool IAsyncResult.IsCompleted
		{
			get
			{
				var v = this.V0 as IAsyncResult;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IAsyncResult type.");

				return v.IsCompleted;
			}
		}

		#endregion

		#region IComparable 成员

		int IComparable.CompareTo(object obj)
		{
			var v = this.V0 as IComparable;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IComparable instance.");

			return v.CompareTo(obj);
		}

		#endregion

		#region IComparer 成员

		int IComparer.Compare(object x, object y)
		{
			var v = this.V0 as IComparer;
			if (v != null)
				return v.Compare(x, y);

			var h = this.V0 as Comparison<object>;
			if (h != null)
				return h(x, y);

			throw new NotSupportedException("V0 mast be an IComparer or Comparison<object> instance.");
		}

		#endregion

		#region ICollection 成员

		void ICollection.CopyTo(Array array, int index)
		{
			var v = this.V0 as ICollection;
			if (v == null)
				throw new NotSupportedException("V0 mast be an ICollection instance.");

			v.CopyTo(array, index);
		}

		int ICollection.Count
		{
			get
			{
				var v = this.V0 as ICollection;
				if (v == null)
					throw new NotSupportedException("V0 mast be an ICollection instance.");

				return v.Count;
			}
		}

		bool ICollection.IsSynchronized
		{
			get
			{
				var v = this.V0 as ICollection;
				if (v == null)
					throw new NotSupportedException("V0 mast be an ICollection instance.");

				return v.IsSynchronized;
			}
		}

		object ICollection.SyncRoot
		{
			get
			{
				var v = this.V0 as ICollection;
				if (v == null)
					throw new NotSupportedException("V0 mast be an ICollection instance.");

				return v.SyncRoot;
			}
		}

		#endregion

		#region IEqualityComparer 成员

		bool IEqualityComparer.Equals(object x, object y)
		{
			var v = this.V0 as IEqualityComparer;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IEqualityComparer instance.");

			return v.Equals(x, y);
		}

		int IEqualityComparer.GetHashCode(object obj)
		{
			var v = this.V0 as IEqualityComparer;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IEqualityComparer instance.");

			return v.GetHashCode(obj);
		}

		#endregion

		#region IEnumerable 成员

		IEnumerator IEnumerable.GetEnumerator()
		{
			var v = this.V0 as IEnumerable;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IEnumerable instance.");

			return v.GetEnumerator();
		}

		#endregion

		#region IEnumerator 成员

		object IEnumerator.Current
		{
			get
			{
				var v = this.V0 as IEnumerator;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IEnumerator instance.");

				return v.Current;
			}
		}

		bool IEnumerator.MoveNext()
		{
			var v = this.V0 as IEnumerator;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IEnumerator instance.");

			return v.MoveNext();
		}

		void IEnumerator.Reset()
		{
			var v = this.V0 as IEnumerator;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IEnumerator instance.");

			v.Reset();
		}

		#endregion

		#region IList 成员

		int IList.Add(object value)
		{
			var v = this.V0 as IList;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IList instance.");

			return v.Add(value);
		}

		void IList.Clear()
		{
			var v = this.V0 as IList;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IList instance.");

			v.Clear();
		}

		bool IList.Contains(object value)
		{
			var v = this.V0 as IList;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IList instance.");

			return v.Contains(value);
		}

		int IList.IndexOf(object value)
		{
			var v = this.V0 as IList;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IList instance.");

			return v.IndexOf(value);
		}

		void IList.Insert(int index, object value)
		{
			var v = this.V0 as IList;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IList instance.");

			v.Insert(index, value);
		}

		bool IList.IsFixedSize
		{
			get
			{
				var v = this.V0 as IList;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IList instance.");

				return v.IsFixedSize;
			}
		}

		bool IList.IsReadOnly
		{
			get
			{
				var v = this.V0 as IList;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IList instance.");

				return v.IsReadOnly;
			}
		}

		void IList.Remove(object value)
		{
			var v = this.V0 as IList;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IList instance.");

			v.Remove(value);
		}

		void IList.RemoveAt(int index)
		{
			var v = this.V0 as IList;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IList instance.");

			v.RemoveAt(index);
		}

		object IList.this[int index]
		{
			get
			{
				var v = this.V0 as IList;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IList instance.");

				return v[index];
			}
			set
			{
				var v = this.V0 as IList;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IList instance.");

				v[index] = value;
			}
		}

		#endregion

		#region IDictionary 成员

		void IDictionary.Add(object key, object value)
		{
			var v = this.V0 as IDictionary;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IDictionary instance.");

			v.Add(key, value);
		}

		void IDictionary.Clear()
		{
			var v = this.V0 as IDictionary;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IDictionary instance.");

			v.Clear();
		}

		bool IDictionary.Contains(object key)
		{
			var v = this.V0 as IDictionary;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IDictionary instance.");

			return v.Contains(key);
		}

		IDictionaryEnumerator IDictionary.GetEnumerator()
		{
			var v = this.V0 as IDictionary;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IDictionary instance.");

			return v.GetEnumerator();
		}

		bool IDictionary.IsFixedSize
		{
			get
			{
				var v = this.V0 as IDictionary;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IDictionary instance.");

				return v.IsFixedSize;
			}
		}

		bool IDictionary.IsReadOnly
		{
			get
			{
				var v = this.V0 as IDictionary;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IDictionary instance.");

				return v.IsReadOnly;
			}
		}

		ICollection IDictionary.Keys
		{
			get
			{
				var v = this.V0 as IDictionary;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IDictionary instance.");

				return v.Keys;
			}
		}

		void IDictionary.Remove(object key)
		{
			var v = this.V0 as IDictionary;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IDictionary instance.");

			v.Remove(key);
		}

		ICollection IDictionary.Values
		{
			get
			{
				var v = this.V0 as IDictionary;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IDictionary instance.");

				return v.Values;
			}
		}

		object IDictionary.this[object key]
		{
			get
			{
				var v = this.V0 as IDictionary;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IDictionary instance.");

				return v[key];
			}
			set
			{
				var v = this.V0 as IDictionary;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IDictionary instance.");

				v[key] = value;
			}
		}

		#endregion

		#region IMethodCallMessage 成员

		object IMethodCallMessage.GetInArg(int argNum)
		{
			var v = this.V0 as IMethodCallMessage;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IMethodCallMessage instance.");

			return v.GetInArg(argNum);
		}

		string IMethodCallMessage.GetInArgName(int index)
		{
			var v = this.V0 as IMethodCallMessage;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IMethodCallMessage instance.");

			return v.GetInArgName(index);
		}

		int IMethodCallMessage.InArgCount
		{
			get
			{
				var v = this.V0 as IMethodCallMessage;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IMethodCallMessage instance.");

				return v.InArgCount;
			}
		}

		object[] IMethodCallMessage.InArgs
		{
			get
			{
				var v = this.V0 as IMethodCallMessage;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IMethodCallMessage instance.");

				return v.InArgs;
			}
		}

		#endregion

		#region IMethodReturnMessage 成员

		Exception IMethodReturnMessage.Exception
		{
			get
			{
				var v = this.V0 as IMethodReturnMessage;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IMethodReturnMessage instance.");

				return v.Exception;
			}
		}

		object IMethodReturnMessage.GetOutArg(int argNum)
		{
			var v = this.V0 as IMethodReturnMessage;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IMethodReturnMessage instance.");

			return v.GetOutArg(argNum);
		}

		string IMethodReturnMessage.GetOutArgName(int index)
		{
			var v = this.V0 as IMethodReturnMessage;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IMethodReturnMessage instance.");

			return v.GetOutArgName(index);
		}

		int IMethodReturnMessage.OutArgCount
		{
			get
			{
				var v = this.V0 as IMethodReturnMessage;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IMethodReturnMessage instance.");

				return v.OutArgCount;
			}
		}

		object[] IMethodReturnMessage.OutArgs
		{
			get
			{
				var v = this.V0 as IMethodReturnMessage;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IMethodReturnMessage instance.");

				return v.OutArgs;
			}
		}

		object IMethodReturnMessage.ReturnValue
		{
			get
			{
				var v = this.V0 as IMethodReturnMessage;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IMethodReturnMessage instance.");

				return v.ReturnValue;
			}
		}

		#endregion

		#region IMethodMessage 成员

		int IMethodMessage.ArgCount
		{
			get
			{
				var v = this.V0 as IMethodMessage;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IMethodMessage instance.");

				return v.ArgCount;
			}
		}

		object[] IMethodMessage.Args
		{
			get
			{
				var v = this.V0 as IMethodMessage;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IMethodMessage instance.");

				return v.Args;
			}
		}

		object IMethodMessage.GetArg(int argNum)
		{
			var v = this.V0 as IMethodMessage;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IMethodMessage instance.");

			return v.GetArg(argNum);
		}

		string IMethodMessage.GetArgName(int index)
		{
			var v = this.V0 as IMethodMessage;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IMethodMessage instance.");

			return v.GetArgName(index);
		}

		bool IMethodMessage.HasVarArgs
		{
			get
			{
				var v = this.V0 as IMethodMessage;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IMethodMessage instance.");

				return v.HasVarArgs;
			}
		}

		LogicalCallContext IMethodMessage.LogicalCallContext
		{
			get
			{
				var v = this.V0 as IMethodMessage;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IMethodMessage instance.");

				return v.LogicalCallContext;
			}
		}

		MethodBase IMethodMessage.MethodBase
		{
			get
			{
				var v = this.V0 as IMethodMessage;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IMethodMessage instance.");

				return v.MethodBase;
			}
		}

		string IMethodMessage.MethodName
		{
			get
			{
				var v = this.V0 as IMethodMessage;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IMethodMessage instance.");

				return v.MethodName;
			}
		}

		object IMethodMessage.MethodSignature
		{
			get
			{
				var v = this.V0 as IMethodMessage;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IMethodMessage instance.");

				return v.MethodSignature;
			}
		}

		string IMethodMessage.TypeName
		{
			get
			{
				var v = this.V0 as IMethodMessage;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IMethodMessage instance.");

				return v.TypeName;
			}
		}

		string IMethodMessage.Uri
		{
			get
			{
				var v = this.V0 as IMethodMessage;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IMethodMessage instance.");

				return v.Uri;
			}
		}

		#endregion

		#region IMessage 成员

		IDictionary IMessage.Properties
		{
			get
			{
				var v = this.V0 as IMessage;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IMessage instance.");

				return v.Properties;
			}
		}

		#endregion

		/// <summary>
		/// 返回传入值的数组，同 T0[] GetArray(Predicate&lt;T0&gt;, T0[])。
		/// </summary>
		/// <param name="predicate">筛选器</param>
		/// <param name="values">传入的值</param>
		/// <returns></returns>
		public static T0[] ToArray(Func<T0, bool> predicate, params T0[] values)
		{
			if (predicate == null)
				return values;

			return values.Where(predicate).ToArray();
		}

		/// <summary>
		/// 返回传入值的数组，同 T0[] ToArray(Func&lt;T0, bool&gt;, T0[])。
		/// </summary>
		/// <param name="predicate">筛选器</param>
		/// <param name="values"></param>
		/// <returns></returns>
		public static T0[] GetArray(Predicate<T0> predicate, params T0[] values)
		{
			if (predicate == null)
				return values;

			return values.Where(item => predicate(item)).ToArray();
		}

		/// <summary>
		/// 执行与释放或重置非托管资源相关的应用程序定义的任务。
		/// </summary>
		public virtual void Dispose()
		{
			var d = this.V0 as IDisposable;
			if (d != null)
				d.Dispose();
		}
	}

	/// <summary>
	/// 通用类
	/// </summary>
	/// <typeparam name="T0">值一的类型</typeparam>
	/// <typeparam name="T1">值二的类型</typeparam>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class Common<T0, T1> : Common<T0>, ICommon<T1>, IComparable<T1>, IComparer<T1>, ICollection<T1>, IEqualityComparer<T1>, IEquatable<T1>, IEnumerable<T1>, IEnumerator<T1>, IList<T1>
	{
		/// <summary>
		/// 值二
		/// </summary>
		public T1 V1;
		/// <summary>
		/// 值托管二
		/// </summary>
		public HByReturnDelegate<T1, T1> H1;

		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		public Common() : base() { }
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="v0">值一</param>
		/// <param name="v1">值二</param>
		public Common(T0 v0, T1 v1)
			: base(v0)
		{
			this.V1 = v1;
		}
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="h0">值委托一</param>
		/// <param name="h1">值委托二</param>
		public Common(HByReturnDelegate<T0, T0> h0, HByReturnDelegate<T1, T1> h1)
			: base(h0)
		{
			this.H1 = h1;
		}

		/// <summary>
		/// 属性值二
		/// </summary>
		public T1 Value1
		{
			set
			{
				this.V1 = value;
			}
			get
			{
				if (this.H1 != null && (this.Initialized & BitUtil.B32_01) == BitUtil.B32_ZERO)
				{
					this.V1 = this.Handler1(this.V1);
					this.Initialized &= BitUtil.B32_01;
				}
				return this.V1;
			}
		}
		/// <summary>
		/// 属性值托管二
		/// </summary>
		public HByReturnDelegate<T1, T1> Handler1
		{
			set
			{
				this.H1 = value;
			}
			get
			{
				return this.H1;
			}
		}

		/// <summary>
		/// 取所有值类型
		/// </summary>
		/// <returns>所有值类型</returns>
		public override Type[] GetTypes()
		{
			return new Type[] { typeof(T0), typeof(T1), };
		}

		/// <summary>
		/// 取所有值委托
		/// </summary>
		/// <returns>所有值委托</returns>
		public override Delegate[] GetHandlers()
		{
			return new Delegate[] { this.H0, this.H1, };
		}

		/// <summary>
		/// 取所有值
		/// </summary>
		/// <returns>所有值</returns>
		public override object[] GetValues()
		{
			return new object[] { this.V0, this.V1, };
		}

		/// <summary>
		/// 返回表示当前 System.Object 的 System.String。
		/// </summary>
		/// <returns>System.String，表示当前的 System.Object。</returns>
		public override string ToString()
		{
			return base.ToString() + ";V1:" + this.V1;
		}

		#region ICommon<T1> 成员

		T1 ICommon<T1>.Value
		{
			set
			{
				this.Value1 = value;
			}
			get
			{
				return this.Value1;
			}
		}

		HByReturnDelegate<T1, T1> ICommon<T1>.Handler
		{
			set
			{
				this.H1 = value;
			}
			get
			{
				return this.H1;
			}
		}

		#endregion

		#region IComparable<T1> 成员

		int IComparable<T1>.CompareTo(T1 other)
		{
			var v = this.V0 as IComparable<T1>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IComparable<" + typeof(T1).FullName + "> instance.");

			return v.CompareTo(other);
		}

		#endregion

		#region IComparer<T1> 成员

		int IComparer<T1>.Compare(T1 x, T1 y)
		{
			var v = this.V0 as IComparer<T1>;
			if (v != null)
				return v.Compare(x, y);

			var h = this.V0 as Comparison<T1>;
			if (h != null)
				return h(x, y);

			throw new NotSupportedException("V0 mast be an IComparer<" + typeof(T1).FullName + "> or Comparison<" + typeof(T1).FullName + "> instance.");
		}

		#endregion

		#region ICollection<T1> 成员

		void ICollection<T1>.Add(T1 item)
		{
			var v = this.V0 as ICollection<T1>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an ICollection<" + typeof(T1).FullName + "> instance.");

			v.Add(item);
		}

		void ICollection<T1>.Clear()
		{
			var v = this.V0 as ICollection<T1>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an ICollection<" + typeof(T1).FullName + "> instance.");

			v.Clear();
		}

		bool ICollection<T1>.Contains(T1 item)
		{
			var v = this.V0 as ICollection<T1>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an ICollection<" + typeof(T1).FullName + "> instance.");

			return v.Contains(item);
		}

		void ICollection<T1>.CopyTo(T1[] array, int arrayIndex)
		{
			var v = this.V0 as ICollection<T1>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an ICollection<" + typeof(T1).FullName + "> type.");

			v.CopyTo(array, arrayIndex);
		}

		int ICollection<T1>.Count
		{
			get
			{
				var v = this.V0 as ICollection<T1>;
				if (v == null)
					throw new NotSupportedException("V0 mast be an ICollection<" + typeof(T1).FullName + "> instance.");

				return v.Count;
			}
		}

		bool ICollection<T1>.IsReadOnly
		{
			get
			{
				var v = this.V0 as ICollection<T1>;
				if (v == null)
					throw new NotSupportedException("V0 mast be an ICollection<" + typeof(T1).FullName + "> instance.");

				return v.IsReadOnly;
			}
		}

		bool ICollection<T1>.Remove(T1 item)
		{
			var v = this.V0 as ICollection<T1>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an ICollection<" + typeof(T1).FullName + "> instance.");

			return v.Remove(item);
		}

		#endregion

		#region IEqualityComparer<T1> 成员

		bool IEqualityComparer<T1>.Equals(T1 x, T1 y)
		{
			var v = this.V0 as IEqualityComparer<T1>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IEqualityComparer<" + typeof(T1).FullName + "> instance.");

			return v.Equals(x, y);
		}

		int IEqualityComparer<T1>.GetHashCode(T1 obj)
		{
			var v = this.V0 as IEqualityComparer<T1>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IEqualityComparer<" + typeof(T1).FullName + "> instance.");

			return v.GetHashCode(obj);
		}

		#endregion

		#region IEquatable<T1> 成员

		bool IEquatable<T1>.Equals(T1 other)
		{
			var v = this.V0 as IEquatable<T1>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IEquatable<" + typeof(T1).FullName + "> instance.");

			return v.Equals(other);
		}

		#endregion

		#region IEnumerable<T1> 成员

		IEnumerator<T1> IEnumerable<T1>.GetEnumerator()
		{
			var v = this.V0 as IEnumerable<T1>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IEnumerable<" + typeof(T1).FullName + "> instance.");

			return v.GetEnumerator();
		}

		#endregion

		#region IEnumerator<T1> 成员

		T1 IEnumerator<T1>.Current
		{
			get
			{
				var v = this.V0 as IEnumerator<T1>;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IEnumerator<" + typeof(T1).FullName + "> instance.");

				return v.Current;
			}
		}

		#endregion

		#region IList<T1> 成员

		int IList<T1>.IndexOf(T1 item)
		{
			var v = this.V0 as IList<T1>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IList<" + typeof(T1).FullName + "> instance.");

			return v.IndexOf(item);
		}

		void IList<T1>.Insert(int index, T1 item)
		{
			var v = this.V0 as IList<T1>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IList<" + typeof(T1).FullName + "> instance.");

			v.Insert(index, item);
		}

		void IList<T1>.RemoveAt(int index)
		{
			var v = this.V0 as IList<T1>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IList<" + typeof(T1).FullName + "> instance.");

			v.RemoveAt(index);
		}

		T1 IList<T1>.this[int index]
		{
			get
			{
				var v = this.V0 as IList<T1>;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IList<" + typeof(T1).FullName + "> instance.");

				return v[index];
			}
			set
			{
				var v = this.V0 as IList<T1>;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IList<" + typeof(T1).FullName + "> instance.");

				v[index] = value;
			}
		}

		#endregion

		/// <summary>
		/// 执行与释放或重置非托管资源相关的应用程序定义的任务。
		/// </summary>
		public override void Dispose()
		{
			var d = this.V1 as IDisposable;
			if (d != null)
				d.Dispose();
			base.Dispose();
		}
	}

	/// <summary>
	/// 通用类
	/// </summary>
	/// <typeparam name="T0">值一的类型</typeparam>
	/// <typeparam name="T1">值二的类型</typeparam>
	/// <typeparam name="T2">值三的类型</typeparam>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class Common<T0, T1, T2> : Common<T0, T1>, ICommon<T2>, IDictionary<T1, T2>
	{
		/// <summary>
		/// 值三
		/// </summary>
		public T2 V2;
		/// <summary>
		/// 值托管三
		/// </summary>
		public HByReturnDelegate<T2, T2> H2;

		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		public Common() : base() { }
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="v0">值一</param>
		/// <param name="v1">值二</param>
		/// <param name="v2">值三</param>
		public Common(T0 v0, T1 v1, T2 v2)
			: base(v0, v1)
		{
			this.V2 = v2;
		}
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="h0">值委托一</param>
		/// <param name="h1">值委托二</param>
		/// <param name="h2">值委托三</param>
		public Common(HByReturnDelegate<T0, T0> h0, HByReturnDelegate<T1, T1> h1, HByReturnDelegate<T2, T2> h2)
			: base(h0, h1)
		{
			this.H2 = h2;
		}

		/// <summary>
		/// 属性值三
		/// </summary>
		public T2 Value2
		{
			set
			{
				this.V2 = value;
			}
			get
			{
				if (this.H2 != null && (this.Initialized & BitUtil.B32_02) == BitUtil.B32_ZERO)
				{
					this.V2 = this.Handler2(this.V2);
					this.Initialized &= BitUtil.B32_02;
				}
				return this.V2;
			}
		}
		/// <summary>
		/// 属性值托管三
		/// </summary>
		public HByReturnDelegate<T2, T2> Handler2
		{
			set
			{
				this.H2 = value;
			}
			get
			{
				return this.H2;
			}
		}

		/// <summary>
		/// 取所有值类型
		/// </summary>
		/// <returns>所有值类型</returns>
		public override Type[] GetTypes()
		{
			return new Type[] { typeof(T0), typeof(T1), typeof(T2), };
		}

		/// <summary>
		/// 取所有值委托
		/// </summary>
		/// <returns>所有值委托</returns>
		public override Delegate[] GetHandlers()
		{
			return new Delegate[] { this.H0, this.H1, this.H2, };
		}

		/// <summary>
		/// 取所有值
		/// </summary>
		/// <returns>所有值</returns>
		public override object[] GetValues()
		{
			return new object[] { this.V0, this.V1, this.V2, };
		}

		/// <summary>
		/// 返回表示当前 System.Object 的 System.String。
		/// </summary>
		/// <returns>System.String，表示当前的 System.Object。</returns>
		public override string ToString()
		{
			return base.ToString() + ";V2:" + this.V2;
		}

		#region ICommon<T2> 成员

		T2 ICommon<T2>.Value
		{
			set
			{
				this.Value2 = value;
			}
			get
			{
				return this.Value2;
			}
		}

		HByReturnDelegate<T2, T2> ICommon<T2>.Handler
		{
			set
			{
				this.H2 = value;
			}
			get
			{
				return this.H2;
			}
		}

		#endregion

		#region IDictionary<T1> 成员

		void IDictionary<T1, T2>.Add(T1 key, T2 value)
		{
			var v = this.V0 as IDictionary<T1, T2>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IDictionary<" + typeof(T1).FullName + ", " + typeof(T2).FullName + "> instance.");

			v.Add(key, value);
		}

		bool IDictionary<T1, T2>.ContainsKey(T1 key)
		{
			var v = this.V0 as IDictionary<T1, T2>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IDictionary<" + typeof(T1).FullName + ", " + typeof(T2).FullName + "> instance.");

			return v.ContainsKey(key);
		}

		ICollection<T1> IDictionary<T1, T2>.Keys
		{
			get
			{
				var v = this.V0 as IDictionary<T1, T2>;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IDictionary<" + typeof(T1).FullName + ", " + typeof(T2).FullName + "> instance.");

				return v.Keys;
			}
		}

		bool IDictionary<T1, T2>.Remove(T1 key)
		{
			var v = this.V0 as IDictionary<T1, T2>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IDictionary<" + typeof(T1).FullName + ", " + typeof(T2).FullName + "> instance.");

			return v.Remove(key);
		}

		bool IDictionary<T1, T2>.TryGetValue(T1 key, out T2 value)
		{
			var v = this.V0 as IDictionary<T1, T2>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IDictionary<" + typeof(T1).FullName + ", " + typeof(T2).FullName + "> instance.");

			return v.TryGetValue(key, out value);
		}

		ICollection<T2> IDictionary<T1, T2>.Values
		{
			get
			{
				var v = this.V0 as IDictionary<T1, T2>;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IDictionary<" + typeof(T1).FullName + ", " + typeof(T2).FullName + "> instance.");

				return v.Values;
			}
		}

		T2 IDictionary<T1, T2>.this[T1 key]
		{
			get
			{
				var v = this.V0 as IDictionary<T1, T2>;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IDictionary<" + typeof(T1).FullName + ", " + typeof(T2).FullName + "> instance.");

				return v[key];
			}
			set
			{
				var v = this.V0 as IDictionary<T1, T2>;
				if (v == null)
					throw new NotSupportedException("V0 mast be an IDictionary<" + typeof(T1).FullName + ", " + typeof(T2).FullName + "> instance.");

				v[key] = value;
			}
		}

		void ICollection<KeyValuePair<T1, T2>>.Add(KeyValuePair<T1, T2> item)
		{
			var v = this.V0 as IDictionary<T1, T2>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IDictionary<" + typeof(T1).FullName + ", " + typeof(T2).FullName + "> instance.");

			v.Add(item);
		}

		void ICollection<KeyValuePair<T1, T2>>.Clear()
		{
			var v = this.V0 as IDictionary<T1, T2>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IDictionary<" + typeof(T1).FullName + ", " + typeof(T2).FullName + "> instance.");

			v.Clear();
		}

		bool ICollection<KeyValuePair<T1, T2>>.Contains(KeyValuePair<T1, T2> item)
		{
			var v = this.V0 as ICollection<KeyValuePair<T1, T2>>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an ICollection<KeyValuePair<" + typeof(T1).FullName + ", " + typeof(T2).FullName + ">> instance.");

			return v.Contains(item);
		}

		void ICollection<KeyValuePair<T1, T2>>.CopyTo(KeyValuePair<T1, T2>[] array, int arrayIndex)
		{
			var v = this.V0 as ICollection<KeyValuePair<T1, T2>>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an ICollection<KeyValuePair<" + typeof(T1).FullName + ", " + typeof(T2).FullName + ">> instance.");

			v.CopyTo(array, arrayIndex);
		}

		int ICollection<KeyValuePair<T1, T2>>.Count
		{
			get
			{
				var v = this.V0 as ICollection<KeyValuePair<T1, T2>>;
				if (v == null)
					throw new NotSupportedException("V0 mast be an ICollection<KeyValuePair<" + typeof(T1).FullName + ", " + typeof(T2).FullName + ">> instance.");

				return v.Count;
			}
		}

		bool ICollection<KeyValuePair<T1, T2>>.IsReadOnly
		{
			get
			{
				var v = this.V0 as ICollection<KeyValuePair<T1, T2>>;
				if (v == null)
					throw new NotSupportedException("V0 mast be an ICollection<KeyValuePair<" + typeof(T1).FullName + ", " + typeof(T2).FullName + ">> instance.");

				return v.IsReadOnly;
			}
		}

		bool ICollection<KeyValuePair<T1, T2>>.Remove(KeyValuePair<T1, T2> item)
		{
			var v = this.V0 as ICollection<KeyValuePair<T1, T2>>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an ICollection<KeyValuePair<" + typeof(T1).FullName + ", " + typeof(T2).FullName + ">> instance.");

			return v.Remove(item);
		}

		IEnumerator<KeyValuePair<T1, T2>> IEnumerable<KeyValuePair<T1, T2>>.GetEnumerator()
		{
			var v = this.V0 as IEnumerable<KeyValuePair<T1, T2>>;
			if (v == null)
				throw new NotSupportedException("V0 mast be an IEnumerable<KeyValuePair<" + typeof(T1).FullName + ", " + typeof(T2).FullName + ">> instance.");

			return v.GetEnumerator();
		}

		#endregion

		/// <summary>
		/// 执行与释放或重置非托管资源相关的应用程序定义的任务。
		/// </summary>
		public override void Dispose()
		{
			var d = this.V2 as IDisposable;
			if (d != null)
				d.Dispose();
			base.Dispose();
		}
	}

	/// <summary>
	/// 通用类
	/// </summary>
	/// <typeparam name="T0">值一的类型</typeparam>
	/// <typeparam name="T1">值二的类型</typeparam>
	/// <typeparam name="T2">值三的类型</typeparam>
	/// <typeparam name="T3">值四的类型</typeparam>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class Common<T0, T1, T2, T3> : Common<T0, T1, T2>, ICommon<T3>
	{
		/// <summary>
		/// 值四
		/// </summary>
		public T3 V3;
		/// <summary>
		/// 值托管四
		/// </summary>
		public HByReturnDelegate<T3, T3> H3;

		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		public Common() : base() { }
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="v0">值一</param>
		/// <param name="v1">值二</param>
		/// <param name="v2">值三</param>
		/// <param name="v3">值四</param>
		public Common(T0 v0, T1 v1, T2 v2, T3 v3)
			: base(v0, v1, v2)
		{
			this.V3 = v3;
		}
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="h0">值委托一</param>
		/// <param name="h1">值委托二</param>
		/// <param name="h2">值委托三</param>
		/// <param name="h3">值委托四</param>
		public Common(HByReturnDelegate<T0, T0> h0, HByReturnDelegate<T1, T1> h1, HByReturnDelegate<T2, T2> h2, HByReturnDelegate<T3, T3> h3)
			: base(h0, h1, h2)
		{
			this.H3 = h3;
		}

		/// <summary>
		/// 属性值四
		/// </summary>
		public T3 Value3
		{
			set
			{
				this.V3 = value;
			}
			get
			{
				if (this.H3 != null && (this.Initialized & BitUtil.B32_03) == BitUtil.B32_ZERO)
				{
					this.V3 = this.Handler3(this.V3);
					this.Initialized &= BitUtil.B32_03;
				}
				return this.V3;
			}
		}
		/// <summary>
		/// 属性值托管四
		/// </summary>
		public HByReturnDelegate<T3, T3> Handler3
		{
			set
			{
				this.H3 = value;
			}
			get
			{
				return this.H3;
			}
		}

		/// <summary>
		/// 取所有值类型
		/// </summary>
		/// <returns>所有值类型</returns>
		public override Type[] GetTypes()
		{
			return new Type[] { typeof(T0), typeof(T1), typeof(T2), typeof(T3), };
		}

		/// <summary>
		/// 取所有值委托
		/// </summary>
		/// <returns>所有值委托</returns>
		public override Delegate[] GetHandlers()
		{
			return new Delegate[] { this.H0, this.H1, this.H2, this.H3, };
		}

		/// <summary>
		/// 取所有值
		/// </summary>
		/// <returns>所有值</returns>
		public override object[] GetValues()
		{
			return new object[] { this.V0, this.V1, this.V2, this.V3, };
		}

		/// <summary>
		/// 返回表示当前 System.Object 的 System.String。
		/// </summary>
		/// <returns>System.String，表示当前的 System.Object。</returns>
		public override string ToString()
		{
			return base.ToString() + ";V3:" + this.V3;
		}

		#region ICommon<T3> 成员

		T3 ICommon<T3>.Value
		{
			set
			{
				this.Value3 = value;
			}
			get
			{
				return this.Value3;
			}
		}

		HByReturnDelegate<T3, T3> ICommon<T3>.Handler
		{
			set
			{
				this.H3 = value;
			}
			get
			{
				return this.H3;
			}
		}

		#endregion

		/// <summary>
		/// 执行与释放或重置非托管资源相关的应用程序定义的任务。
		/// </summary>
		public override void Dispose()
		{
			var d = this.V3 as IDisposable;
			if (d != null)
				d.Dispose();
			base.Dispose();
		}
	}

	/// <summary>
	/// 通用类
	/// </summary>
	/// <typeparam name="T0">值一的类型</typeparam>
	/// <typeparam name="T1">值二的类型</typeparam>
	/// <typeparam name="T2">值三的类型</typeparam>
	/// <typeparam name="T3">值四的类型</typeparam>
	/// <typeparam name="T4">值五的类型</typeparam>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class Common<T0, T1, T2, T3, T4> : Common<T0, T1, T2, T3>, ICommon<T4>
	{
		/// <summary>
		/// 值五
		/// </summary>
		public T4 V4;
		/// <summary>
		/// 值托管五
		/// </summary>
		public HByReturnDelegate<T4, T4> H4;

		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		public Common() : base() { }
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="v0">值一</param>
		/// <param name="v1">值二</param>
		/// <param name="v2">值三</param>
		/// <param name="v3">值四</param>
		/// <param name="v4">值五</param>
		public Common(T0 v0, T1 v1, T2 v2, T3 v3, T4 v4)
			: base(v0, v1, v2, v3)
		{
			this.V4 = v4;
		}
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="h0">值委托一</param>
		/// <param name="h1">值委托二</param>
		/// <param name="h2">值委托三</param>
		/// <param name="h3">值委托四</param>
		/// <param name="h4">值委托五</param>
		public Common(HByReturnDelegate<T0, T0> h0, HByReturnDelegate<T1, T1> h1, HByReturnDelegate<T2, T2> h2, HByReturnDelegate<T3, T3> h3, HByReturnDelegate<T4, T4> h4)
			: base(h0, h1, h2, h3)
		{
			this.H4 = h4;
		}

		/// <summary>
		/// 属性值五
		/// </summary>
		public T4 Value4
		{
			set
			{
				this.V4 = value;
			}
			get
			{
				if (this.H4 != null && (this.Initialized & BitUtil.B32_04) == BitUtil.B32_ZERO)
				{
					this.V4 = this.Handler4(this.V4);
					this.Initialized &= BitUtil.B32_04;
				}
				return this.V4;
			}
		}
		/// <summary>
		/// 属性值托管五
		/// </summary>
		public HByReturnDelegate<T4, T4> Handler4
		{
			set
			{
				this.H4 = value;
			}
			get
			{
				return this.H4;
			}
		}

		/// <summary>
		/// 取所有值类型
		/// </summary>
		/// <returns>所有值类型</returns>
		public override Type[] GetTypes()
		{
			return new Type[] { typeof(T0), typeof(T1), typeof(T2), typeof(T3), typeof(T4), };
		}

		/// <summary>
		/// 取所有值委托
		/// </summary>
		/// <returns>所有值委托</returns>
		public override Delegate[] GetHandlers()
		{
			return new Delegate[] { this.H0, this.H1, this.H2, this.H3, this.H4, };
		}

		/// <summary>
		/// 取所有值
		/// </summary>
		/// <returns>所有值</returns>
		public override object[] GetValues()
		{
			return new object[] { this.V0, this.V1, this.V2, this.V3, this.V4, };
		}

		/// <summary>
		/// 返回表示当前 System.Object 的 System.String。
		/// </summary>
		/// <returns>System.String，表示当前的 System.Object。</returns>
		public override string ToString()
		{
			return base.ToString() + ";V4:" + this.V4;
		}

		#region ICommon<T4> 成员

		T4 ICommon<T4>.Value
		{
			set
			{
				this.Value4 = value;
			}
			get
			{
				return this.Value4;
			}
		}

		HByReturnDelegate<T4, T4> ICommon<T4>.Handler
		{
			set
			{
				this.H4 = value;
			}
			get
			{
				return this.H4;
			}
		}

		#endregion

		/// <summary>
		/// 执行与释放或重置非托管资源相关的应用程序定义的任务。
		/// </summary>
		public override void Dispose()
		{
			var d = this.V4 as IDisposable;
			if (d != null)
				d.Dispose();
			base.Dispose();
		}
	}

	/// <summary>
	/// 通用类
	/// </summary>
	/// <typeparam name="T0">值一的类型</typeparam>
	/// <typeparam name="T1">值二的类型</typeparam>
	/// <typeparam name="T2">值三的类型</typeparam>
	/// <typeparam name="T3">值四的类型</typeparam>
	/// <typeparam name="T4">值五的类型</typeparam>
	/// <typeparam name="T5">值六的类型</typeparam>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class Common<T0, T1, T2, T3, T4, T5> : Common<T0, T1, T2, T3, T4>, ICommon<T5>
	{
		/// <summary>
		/// 值六
		/// </summary>
		public T5 V5;
		/// <summary>
		/// 值托管六
		/// </summary>
		public HByReturnDelegate<T5, T5> H5;

		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		public Common() : base() { }
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="v0">值一</param>
		/// <param name="v1">值二</param>
		/// <param name="v2">值三</param>
		/// <param name="v3">值四</param>
		/// <param name="v4">值五</param>
		/// <param name="v5">值六</param>
		public Common(T0 v0, T1 v1, T2 v2, T3 v3, T4 v4, T5 v5)
			: base(v0, v1, v2, v3, v4)
		{
			this.V5 = v5;
		}
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="h0">值委托一</param>
		/// <param name="h1">值委托二</param>
		/// <param name="h2">值委托三</param>
		/// <param name="h3">值委托四</param>
		/// <param name="h4">值委托五</param>
		/// <param name="h5">值委托六</param>
		public Common(HByReturnDelegate<T0, T0> h0, HByReturnDelegate<T1, T1> h1, HByReturnDelegate<T2, T2> h2, HByReturnDelegate<T3, T3> h3, HByReturnDelegate<T4, T4> h4, HByReturnDelegate<T5, T5> h5)
			: base(h0, h1, h2, h3, h4)
		{
			this.H5 = h5;
		}

		/// <summary>
		/// 属性值六
		/// </summary>
		public T5 Value5
		{
			set
			{
				this.V5 = value;
			}
			get
			{
				if (this.H5 != null && (this.Initialized & BitUtil.B32_05) == BitUtil.B32_ZERO)
				{
					this.V5 = this.Handler5(this.V5);
					this.Initialized &= BitUtil.B32_05;
				}
				return this.V5;
			}
		}
		/// <summary>
		/// 属性值托管六
		/// </summary>
		public HByReturnDelegate<T5, T5> Handler5
		{
			set
			{
				this.H5 = value;
			}
			get
			{
				return this.H5;
			}
		}

		/// <summary>
		/// 取所有值类型
		/// </summary>
		/// <returns>所有值类型</returns>
		public override Type[] GetTypes()
		{
			return new Type[] { typeof(T0), typeof(T1), typeof(T2), typeof(T3), typeof(T4), typeof(T5), };
		}

		/// <summary>
		/// 取所有值委托
		/// </summary>
		/// <returns>所有值委托</returns>
		public override Delegate[] GetHandlers()
		{
			return new Delegate[] { this.H0, this.H1, this.H2, this.H3, this.H4, this.H5, };
		}

		/// <summary>
		/// 取所有值
		/// </summary>
		/// <returns>所有值</returns>
		public override object[] GetValues()
		{
			return new object[] { this.V0, this.V1, this.V2, this.V3, this.V4, this.V5, };
		}

		/// <summary>
		/// 返回表示当前 System.Object 的 System.String。
		/// </summary>
		/// <returns>System.String，表示当前的 System.Object。</returns>
		public override string ToString()
		{
			return base.ToString() + ";V5:" + this.V5;
		}

		#region ICommon<T5> 成员

		T5 ICommon<T5>.Value
		{
			set
			{
				this.Value5 = value;
			}
			get
			{
				return this.Value5;
			}
		}

		HByReturnDelegate<T5, T5> ICommon<T5>.Handler
		{
			set
			{
				this.H5 = value;
			}
			get
			{
				return this.H5;
			}
		}

		#endregion

		/// <summary>
		/// 执行与释放或重置非托管资源相关的应用程序定义的任务。
		/// </summary>
		public override void Dispose()
		{
			var d = this.V5 as IDisposable;
			if (d != null)
				d.Dispose();
			base.Dispose();
		}
	}

	/// <summary>
	/// 通用类
	/// </summary>
	/// <typeparam name="T0">值一的类型</typeparam>
	/// <typeparam name="T1">值二的类型</typeparam>
	/// <typeparam name="T2">值三的类型</typeparam>
	/// <typeparam name="T3">值四的类型</typeparam>
	/// <typeparam name="T4">值五的类型</typeparam>
	/// <typeparam name="T5">值六的类型</typeparam>
	/// <typeparam name="T6">值七的类型</typeparam>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class Common<T0, T1, T2, T3, T4, T5, T6> : Common<T0, T1, T2, T3, T4, T5>, ICommon<T6>
	{
		/// <summary>
		/// 值七
		/// </summary>
		public T6 V6;
		/// <summary>
		/// 值托管七
		/// </summary>
		public HByReturnDelegate<T6, T6> H6;

		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		public Common() : base() { }
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="v0">值一</param>
		/// <param name="v1">值二</param>
		/// <param name="v2">值三</param>
		/// <param name="v3">值四</param>
		/// <param name="v4">值五</param>
		/// <param name="v5">值六</param>
		/// <param name="v6">值七</param>
		public Common(T0 v0, T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6)
			: base(v0, v1, v2, v3, v4, v5)
		{
			this.V6 = v6;
		}
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="h0">值委托一</param>
		/// <param name="h1">值委托二</param>
		/// <param name="h2">值委托三</param>
		/// <param name="h3">值委托四</param>
		/// <param name="h4">值委托五</param>
		/// <param name="h5">值委托六</param>
		/// <param name="h6">值委托七</param>
		public Common(HByReturnDelegate<T0, T0> h0, HByReturnDelegate<T1, T1> h1, HByReturnDelegate<T2, T2> h2, HByReturnDelegate<T3, T3> h3, HByReturnDelegate<T4, T4> h4, HByReturnDelegate<T5, T5> h5, HByReturnDelegate<T6, T6> h6)
			: base(h0, h1, h2, h3, h4, h5)
		{
			this.H6 = h6;
		}

		/// <summary>
		/// 属性值七
		/// </summary>
		public T6 Value6
		{
			set
			{
				this.V6 = value;
			}
			get
			{
				if (this.H6 != null && (this.Initialized & BitUtil.B32_06) == BitUtil.B32_ZERO)
				{
					this.V6 = this.Handler6(this.V6);
					this.Initialized &= BitUtil.B32_06;
				}
				return this.V6;
			}
		}
		/// <summary>
		/// 属性值托管七
		/// </summary>
		public HByReturnDelegate<T6, T6> Handler6
		{
			set
			{
				this.H6 = value;
			}
			get
			{
				return this.H6;
			}
		}

		/// <summary>
		/// 取所有值类型
		/// </summary>
		/// <returns>所有值类型</returns>
		public override Type[] GetTypes()
		{
			return new Type[] { typeof(T0), typeof(T1), typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), };
		}

		/// <summary>
		/// 取所有值委托
		/// </summary>
		/// <returns>所有值委托</returns>
		public override Delegate[] GetHandlers()
		{
			return new Delegate[] { this.H0, this.H1, this.H2, this.H3, this.H4, this.H5, this.H6, };
		}

		/// <summary>
		/// 取所有值
		/// </summary>
		/// <returns>所有值</returns>
		public override object[] GetValues()
		{
			return new object[] { this.V0, this.V1, this.V2, this.V3, this.V4, this.V5, this.V6, };
		}

		/// <summary>
		/// 返回表示当前 System.Object 的 System.String。
		/// </summary>
		/// <returns>System.String，表示当前的 System.Object。</returns>
		public override string ToString()
		{
			return base.ToString() + ";V6:" + this.V6;
		}

		#region ICommon<T6> 成员

		T6 ICommon<T6>.Value
		{
			set
			{
				this.Value6 = value;
			}
			get
			{
				return this.Value6;
			}
		}

		HByReturnDelegate<T6, T6> ICommon<T6>.Handler
		{
			set
			{
				this.H6 = value;
			}
			get
			{
				return this.H6;
			}
		}

		#endregion

		/// <summary>
		/// 执行与释放或重置非托管资源相关的应用程序定义的任务。
		/// </summary>
		public override void Dispose()
		{
			var d = this.V6 as IDisposable;
			if (d != null)
				d.Dispose();
			base.Dispose();
		}
	}

	/// <summary>
	/// 通用类
	/// </summary>
	/// <typeparam name="T0">值一的类型</typeparam>
	/// <typeparam name="T1">值二的类型</typeparam>
	/// <typeparam name="T2">值三的类型</typeparam>
	/// <typeparam name="T3">值四的类型</typeparam>
	/// <typeparam name="T4">值五的类型</typeparam>
	/// <typeparam name="T5">值六的类型</typeparam>
	/// <typeparam name="T6">值七的类型</typeparam>
	/// <typeparam name="T7">值八的类型</typeparam>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class Common<T0, T1, T2, T3, T4, T5, T6, T7> : Common<T0, T1, T2, T3, T4, T5, T6>, ICommon<T7>
	{
		/// <summary>
		/// 值八
		/// </summary>
		public T7 V7;
		/// <summary>
		/// 值托管八
		/// </summary>
		public HByReturnDelegate<T7, T7> H7;

		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		public Common() : base() { }
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="v0">值一</param>
		/// <param name="v1">值二</param>
		/// <param name="v2">值三</param>
		/// <param name="v3">值四</param>
		/// <param name="v4">值五</param>
		/// <param name="v5">值六</param>
		/// <param name="v6">值七</param>
		/// <param name="v7">值八</param>
		public Common(T0 v0, T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7)
			: base(v0, v1, v2, v3, v4, v5, v6)
		{
			this.V7 = v7;
		}
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="h0">值委托一</param>
		/// <param name="h1">值委托二</param>
		/// <param name="h2">值委托三</param>
		/// <param name="h3">值委托四</param>
		/// <param name="h4">值委托五</param>
		/// <param name="h5">值委托六</param>
		/// <param name="h6">值委托七</param>
		/// <param name="h7">值委托八</param>
		public Common(HByReturnDelegate<T0, T0> h0, HByReturnDelegate<T1, T1> h1, HByReturnDelegate<T2, T2> h2, HByReturnDelegate<T3, T3> h3, HByReturnDelegate<T4, T4> h4, HByReturnDelegate<T5, T5> h5, HByReturnDelegate<T6, T6> h6, HByReturnDelegate<T7, T7> h7)
			: base(h0, h1, h2, h3, h4, h5, h6)
		{
			this.H7 = h7;
		}

		/// <summary>
		/// 属性值八
		/// </summary>
		public T7 Value7
		{
			set
			{
				this.V7 = value;
			}
			get
			{
				if (this.H7 != null && (this.Initialized & BitUtil.B32_07) == BitUtil.B32_ZERO)
				{
					this.V7 = this.Handler7(this.V7);
					this.Initialized &= BitUtil.B32_07;
				}
				return this.V7;
			}
		}
		/// <summary>
		/// 属性值托管八
		/// </summary>
		public HByReturnDelegate<T7, T7> Handler7
		{
			set
			{
				this.H7 = value;
			}
			get
			{
				return this.H7;
			}
		}

		/// <summary>
		/// 取所有值类型
		/// </summary>
		/// <returns>所有值类型</returns>
		public override Type[] GetTypes()
		{
			return new Type[] { typeof(T0), typeof(T1), typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), };
		}

		/// <summary>
		/// 取所有值委托
		/// </summary>
		/// <returns>所有值委托</returns>
		public override Delegate[] GetHandlers()
		{
			return new Delegate[] { this.H0, this.H1, this.H2, this.H3, this.H4, this.H5, this.H6, this.H7, };
		}

		/// <summary>
		/// 取所有值
		/// </summary>
		/// <returns>所有值</returns>
		public override object[] GetValues()
		{
			return new object[] { this.V0, this.V1, this.V2, this.V3, this.V4, this.V5, this.V6, this.V7, };
		}

		/// <summary>
		/// 返回表示当前 System.Object 的 System.String。
		/// </summary>
		/// <returns>System.String，表示当前的 System.Object。</returns>
		public override string ToString()
		{
			return base.ToString() + ";V7:" + this.V7;
		}

		#region ICommon<T7> 成员

		T7 ICommon<T7>.Value
		{
			set
			{
				this.Value7 = value;
			}
			get
			{
				return this.Value7;
			}
		}

		HByReturnDelegate<T7, T7> ICommon<T7>.Handler
		{
			set
			{
				this.H7 = value;
			}
			get
			{
				return this.H7;
			}
		}

		#endregion

		/// <summary>
		/// 执行与释放或重置非托管资源相关的应用程序定义的任务。
		/// </summary>
		public override void Dispose()
		{
			var d = this.V7 as IDisposable;
			if (d != null)
				d.Dispose();
			base.Dispose();
		}
	}

	/// <summary>
	/// 通用类
	/// </summary>
	/// <typeparam name="T0">值一的类型</typeparam>
	/// <typeparam name="T1">值二的类型</typeparam>
	/// <typeparam name="T2">值三的类型</typeparam>
	/// <typeparam name="T3">值四的类型</typeparam>
	/// <typeparam name="T4">值五的类型</typeparam>
	/// <typeparam name="T5">值六的类型</typeparam>
	/// <typeparam name="T6">值七的类型</typeparam>
	/// <typeparam name="T7">值八的类型</typeparam>
	/// <typeparam name="T8">值九的类型</typeparam>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class Common<T0, T1, T2, T3, T4, T5, T6, T7, T8> : Common<T0, T1, T2, T3, T4, T5, T6, T7>, ICommon<T8>
	{
		/// <summary>
		/// 值九
		/// </summary>
		public T8 V8;
		/// <summary>
		/// 值托管九
		/// </summary>
		public HByReturnDelegate<T8, T8> H8;

		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		public Common() : base() { }
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="v0">值一</param>
		/// <param name="v1">值二</param>
		/// <param name="v2">值三</param>
		/// <param name="v3">值四</param>
		/// <param name="v4">值五</param>
		/// <param name="v5">值六</param>
		/// <param name="v6">值七</param>
		/// <param name="v7">值八</param>
		/// <param name="v8">值九</param>
		public Common(T0 v0, T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8)
			: base(v0, v1, v2, v3, v4, v5, v6, v7)
		{
			this.V8 = v8;
		}
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="h0">值委托一</param>
		/// <param name="h1">值委托二</param>
		/// <param name="h2">值委托三</param>
		/// <param name="h3">值委托四</param>
		/// <param name="h4">值委托五</param>
		/// <param name="h5">值委托六</param>
		/// <param name="h6">值委托七</param>
		/// <param name="h7">值委托八</param>
		/// <param name="h8">值委托九</param>
		public Common(HByReturnDelegate<T0, T0> h0, HByReturnDelegate<T1, T1> h1, HByReturnDelegate<T2, T2> h2, HByReturnDelegate<T3, T3> h3, HByReturnDelegate<T4, T4> h4, HByReturnDelegate<T5, T5> h5, HByReturnDelegate<T6, T6> h6, HByReturnDelegate<T7, T7> h7, HByReturnDelegate<T8, T8> h8)
			: base(h0, h1, h2, h3, h4, h5, h6, h7)
		{
			this.H8 = h8;
		}

		/// <summary>
		/// 属性值九
		/// </summary>
		public T8 Value8
		{
			set
			{
				this.V8 = value;
			}
			get
			{
				if (this.H8 != null && (this.Initialized & BitUtil.B32_08) == BitUtil.B32_ZERO)
				{
					this.V8 = this.Handler8(this.V8);
					this.Initialized &= BitUtil.B32_08;
				}
				return this.V8;
			}
		}
		/// <summary>
		/// 属性值托管九
		/// </summary>
		public HByReturnDelegate<T8, T8> Handler8
		{
			set
			{
				this.H8 = value;
			}
			get
			{
				return this.H8;
			}
		}

		/// <summary>
		/// 取所有值类型
		/// </summary>
		/// <returns>所有值类型</returns>
		public override Type[] GetTypes()
		{
			return new Type[] { typeof(T0), typeof(T1), typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), };
		}

		/// <summary>
		/// 取所有值委托
		/// </summary>
		/// <returns>所有值委托</returns>
		public override Delegate[] GetHandlers()
		{
			return new Delegate[] { this.H0, this.H1, this.H2, this.H3, this.H4, this.H5, this.H6, this.H7, this.H8, };
		}

		/// <summary>
		/// 取所有值
		/// </summary>
		/// <returns>所有值</returns>
		public override object[] GetValues()
		{
			return new object[] { this.V0, this.V1, this.V2, this.V3, this.V4, this.V5, this.V6, this.V7, this.V8, };
		}

		/// <summary>
		/// 返回表示当前 System.Object 的 System.String。
		/// </summary>
		/// <returns>System.String，表示当前的 System.Object。</returns>
		public override string ToString()
		{
			return base.ToString() + ";V8:" + this.V8;
		}

		#region ICommon<T8> 成员

		T8 ICommon<T8>.Value
		{
			set
			{
				this.Value8 = value;
			}
			get
			{
				return this.Value8;
			}
		}

		HByReturnDelegate<T8, T8> ICommon<T8>.Handler
		{
			set
			{
				this.H8 = value;
			}
			get
			{
				return this.H8;
			}
		}

		#endregion

		/// <summary>
		/// 执行与释放或重置非托管资源相关的应用程序定义的任务。
		/// </summary>
		public override void Dispose()
		{
			var d = this.V8 as IDisposable;
			if (d != null)
				d.Dispose();
			base.Dispose();
		}
	}

	/// <summary>
	/// 通用类
	/// </summary>
	/// <typeparam name="T0">值一的类型</typeparam>
	/// <typeparam name="T1">值二的类型</typeparam>
	/// <typeparam name="T2">值三的类型</typeparam>
	/// <typeparam name="T3">值四的类型</typeparam>
	/// <typeparam name="T4">值五的类型</typeparam>
	/// <typeparam name="T5">值六的类型</typeparam>
	/// <typeparam name="T6">值七的类型</typeparam>
	/// <typeparam name="T7">值八的类型</typeparam>
	/// <typeparam name="T8">值九的类型</typeparam>
	/// <typeparam name="T9">值十的类型</typeparam>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class Common<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> : Common<T0, T1, T2, T3, T4, T5, T6, T7, T8>, ICommon<T9>
	{
		/// <summary>
		/// 值十
		/// </summary>
		public T9 V9;
		/// <summary>
		/// 值托管十
		/// </summary>
		public HByReturnDelegate<T9, T9> H9;

		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		public Common() : base() { }
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="v0">值一</param>
		/// <param name="v1">值二</param>
		/// <param name="v2">值三</param>
		/// <param name="v3">值四</param>
		/// <param name="v4">值五</param>
		/// <param name="v5">值六</param>
		/// <param name="v6">值七</param>
		/// <param name="v7">值八</param>
		/// <param name="v8">值九</param>
		/// <param name="v9">值十</param>
		public Common(T0 v0, T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9)
			: base(v0, v1, v2, v3, v4, v5, v6, v7, v8)
		{
			this.V9 = v9;
		}
		/// <summary>
		/// 构造一个通用类型
		/// </summary>
		/// <param name="h0">值委托一</param>
		/// <param name="h1">值委托二</param>
		/// <param name="h2">值委托三</param>
		/// <param name="h3">值委托四</param>
		/// <param name="h4">值委托五</param>
		/// <param name="h5">值委托六</param>
		/// <param name="h6">值委托七</param>
		/// <param name="h7">值委托八</param>
		/// <param name="h8">值委托九</param>
		/// <param name="h9">值委托十</param>
		public Common(HByReturnDelegate<T0, T0> h0, HByReturnDelegate<T1, T1> h1, HByReturnDelegate<T2, T2> h2, HByReturnDelegate<T3, T3> h3, HByReturnDelegate<T4, T4> h4, HByReturnDelegate<T5, T5> h5, HByReturnDelegate<T6, T6> h6, HByReturnDelegate<T7, T7> h7, HByReturnDelegate<T8, T8> h8, HByReturnDelegate<T9, T9> h9)
			: base(h0, h1, h2, h3, h4, h5, h6, h7, h8)
		{
			this.H9 = h9;
		}

		/// <summary>
		/// 属性值十
		/// </summary>
		public T9 Value9
		{
			set
			{
				this.V9 = value;
			}
			get
			{
				if (this.H9 != null && (this.Initialized & BitUtil.B32_09) == BitUtil.B32_ZERO)
				{
					this.V9 = this.Handler9(this.V9);
					this.Initialized &= BitUtil.B32_09;
				}
				return this.V9;
			}
		}
		/// <summary>
		/// 属性值托管十
		/// </summary>
		public HByReturnDelegate<T9, T9> Handler9
		{
			set
			{
				this.H9 = value;
			}
			get
			{
				return this.H9;
			}
		}

		/// <summary>
		/// 取所有值类型
		/// </summary>
		/// <returns>所有值类型</returns>
		public override Type[] GetTypes()
		{
			return new Type[] { typeof(T0), typeof(T1), typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), };
		}

		/// <summary>
		/// 取所有值委托
		/// </summary>
		/// <returns>所有值委托</returns>
		public override Delegate[] GetHandlers()
		{
			return new Delegate[] { this.H0, this.H1, this.H2, this.H3, this.H4, this.H5, this.H6, this.H7, this.H8, this.H9, };
		}

		/// <summary>
		/// 取所有值
		/// </summary>
		/// <returns>所有值</returns>
		public override object[] GetValues()
		{
			return new object[] { this.V0, this.V1, this.V2, this.V3, this.V4, this.V5, this.V6, this.V7, this.V8, this.V9, };
		}

		/// <summary>
		/// 返回表示当前 System.Object 的 System.String。
		/// </summary>
		/// <returns>System.String，表示当前的 System.Object。</returns>
		public override string ToString()
		{
			return base.ToString() + ";V9:" + this.V9;
		}

		#region ICommon<T9> 成员

		T9 ICommon<T9>.Value
		{
			set
			{
				this.Value9 = value;
			}
			get
			{
				return this.Value9;
			}
		}

		HByReturnDelegate<T9, T9> ICommon<T9>.Handler
		{
			set
			{
				this.H9 = value;
			}
			get
			{
				return this.H9;
			}
		}

		#endregion

		/// <summary>
		/// 执行与释放或重置非托管资源相关的应用程序定义的任务。
		/// </summary>
		public override void Dispose()
		{
			var d = this.V9 as IDisposable;
			if (d != null)
				d.Dispose();
			base.Dispose();
		}
	}
}
